package xpn.business.fund_return.entity.capital_flow_statement;

import org.springframework.context.ApplicationContextException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class CapitalFlowStatementService {
    @Resource
    private CapitalFlowStatementDao capitalFlowStatementDao;

//    @Resource
//    private FrCaseService frCaseService;

    public CapitalFlowStatement save(CapitalFlowStatement capitalFlowStatement) {
        if (Objects.isNull(capitalFlowStatement.getId())) {
            CapitalFlowStatement exist = capitalFlowStatementDao.findAllByCaseId(capitalFlowStatement.getCaseId());
            if (Objects.nonNull(exist)) {
                throw new ApplicationContextException("该表单已存在，请勿重复创建");
            }
        }
//        frCaseService.changeWriteStatus(capitalFlowStatement.getCaseId(), CaseWriteStatus.CapitalFlow);
        return capitalFlowStatementDao.save(capitalFlowStatement);
    }
}
